import Taro, { Component, Config } from '@tarojs/taro'
import { connect } from '@tarojs/redux'
import { View, Text } from '@tarojs/components'
import YTableDivider from '../../components/YTableDivider'
import './Questions.scss'

import { fetch } from '../../actions/questions'

@connect(({ questions }) => ({
  questions
}), (dispatch) => ({
  fetch() {
    dispatch(fetch())
  }
}))
export default class extends Component {
  config: Config = {
    navigationBarTitleText: '常见问题'
  }

  componentWillReceiveProps(nextProps) {
    console.log(this.props, nextProps)
  }

  componentWillMount() {

    this.props.fetch()

  }

  componentWillUnmount() { }

  componentDidShow() { }

  componentDidHide() { }

  onGetPhoneNumber = msg => {
    console.log(msg)
  }

  render() {
    return (
      <View className='article_1543485218582'>
        {
          this.props.questions.data.data.map((item, k) => (
            <View className='cell' key={k}>
              <YTableDivider title={item.title} />
              <View className='content'>
                <Text className='text'>
                  {item.brief}
                </Text>
              </View>          
            </View>
          ))
        }
      </View>
    )
  }
}
